<?php
// +----------------------------------------------------------------------
// | Tplay [ WE ONLY DO WHAT IS NECESSARY ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017 http://tplay.pengyichen.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 听雨 < 389625819@qq.com >
// +----------------------------------------------------------------------


namespace app\admin\model;

use \think\Model;
class Integral extends Model
{
    //获取商城消费积分基数
    public function getConsumeIntegral()
    {
        $integral = $this->where("types",1)->field("integra")->find();
        return empty($integral['integra'])?0:$integral['integra'];
    }
    //获取商品评论积分基数
    public function getShopCommentIntegral()
    {
        $integral = $this->where("types",2)->field("integra")->find();
        return empty($integral['integra'])?0:$integral['integra'];
    }
    //获取PO评论积分基数
    public function getPOICommentIntegral()
    {
        $integral = $this->where("types",3)->field("integra")->find();
        return empty($integral['integra'])?0:$integral['integra'];
    }
    //获取积分类型对应的积分数
    public function getIntegralNumber($type)
    {
        switch ($type){
            case 1:
                $inte = $this->getConsumeIntegral();
                break;
            case 2:
                $inte = $this->getShopCommentIntegral();
                break;
            case 3:
                $inte = $this->getPOICommentIntegral();
                break;
            default:
                $inte = 0;
                break;
        }

        return $inte;
    }

}